<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <script src="js/jquery-3.6.0.js"></script>
    <style>
        tr:nth-of-type(odd){
            background-color: dimgray;
        }
    </style>
</head>
<body>
    <table border="1px">
        <tr>
            <th>类别</th>
            <th>品种</th>
            <th>产地</th>
            <th>总重量(公斤)</th>
            <th>单价(元/公斤)</th>
            <th>操作</th>
        </tr>
        <c:forEach items="${list}" var="list">
            <tr>
                <th>${list.type}</th>
                <th>${list.breed}</th>
                <th>${list.area}</th>
                <th>${list.weight}</th>
                <th>${list.price}</th>
                <th>
                    <a href="FruitDetail?fruitId=${list.fruitId}">详细</a>
                    <a href="javascript:void(0)" onclick="del(#{list.fruitId})">删除</a>
                </th>
            </tr>
        </c:forEach>
    </table>
</body>
<script>
    function del(fruitId){
        if (confirm("确定要删除吗?")){
            $.get("FruitDelete","fruitId="+fruitId,function (data){
                if (data == "true"){
                    alert("删除成功!")
                    location.reload();
                }else{
                    alert("删除失败!")
                    location.reload();
                }
            })
        }
    }
</script>
</html>
